<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page isELIgnored="false" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <base href="<%=request.getContextPath()%>/">
    <title>用车申请管理后台</title>
    <link rel="stylesheet" href="static/layui/css/layui.css">
    <link rel="stylesheet" href="static/css/base.css">
    <script src="static/js/jquery.js"></script>
    <script src="static/js/ajax.js"></script>
    <script src="static/layui/layui.js"></script>
    <style>
        .layui-icon {
            display: inline-block;
            width: 20px;
            margin-right: 10px;
        }
    </style>
</head>
<div class="layui-layout layui-layout-admin">
    <div class="layui-header">
        <div class="layui-logo layui-hide-xs layui-bg-black">
            <a href="welcome" onclick="homeClick()" target="content" style="color: #cccccc">用车申请后台</a>
        </div>
        <!-- 头部区域（可配合layui 已有的水平导航） -->
        <ul class="layui-nav layui-layout-right">
            <li class="layui-nav-item layui-hide layui-show-sm-inline-block">
                <a href="javascript:;">
                    <img id="avatar" src="${loginInfo.avatar}" class="layui-nav-img">
                    <span id="nickname">${loginInfo.nickname}</span>
                </a>
                <dl class="layui-nav-child">
                    <dd><a href="javascript:;" onclick="showUserWin()">个人信息</a></dd>
                    <dd><a href="javascript:;" onclick="showPasswordWin()">修改密码</a></dd>
                    <dd><a href="javascript:;" onclick="logout()">退出系统</a></dd>
                </dl>
            </li>
        </ul>
    </div>
    <div class="layui-side layui-bg-black">
        <div class="layui-side-scroll">
            <!-- 左侧导航区域（可配合layui已有的垂直导航） -->
            <ul class="layui-nav layui-nav-tree " lay-filter="test">
                <c:if test="${loginInfo.role == 2 || loginInfo.role == 3}">
                    <li class="layui-nav-item">
                        <a href="apply?type=apply" target="content"><i class="layui-icon layui-icon-survey"></i>申请用车</a>
                    </li>
                </c:if>
                <c:if test="${loginInfo.role == 1 || loginInfo.role == 2}">
                    <li class="layui-nav-item">
                        <a href="javascript:;"><i class="layui-icon layui-icon-group"></i>用户管理</a>
                        <dl class="layui-nav-child">
                            <dd><a href="userinfo" target="content">用户列表</a></dd>
                            <c:if test="${loginInfo.role == 1}">
                                <dd><a href="department" target="content">部门列表</a></dd>
                            </c:if>
                        </dl>
                    </li>
                </c:if>
                <c:if test="${loginInfo.role == 1 || loginInfo.role == 4}">
                    <li class="layui-nav-item">
                        <a href="javascript:;"><i class="layui-icon layui-icon-flag"></i>车辆管理</a>
                        <dl class="layui-nav-child">
                            <dd><a href="category" target="content">类型列表</a></dd>
                            <dd><a href="car" target="content">汽车列表</a></dd>
                        </dl>
                    </li>
                </c:if>
                <li class="layui-nav-item">
                    <a class="" href="javascript:;"><i class="layui-icon layui-icon-form"></i>记录管理</a>
                    <dl class="layui-nav-child">
                        <c:if test="${loginInfo.role == 2 || loginInfo.role == 3}">
                            <dd><a href="apply/list" target="content">我的申请</a></dd>
                        </c:if>
                        <c:if test="${loginInfo.role == 2 || loginInfo.role == 1}">
                            <dd><a href="apply/exam" target="content">审核列表</a></dd>
                        </c:if>
                        <dd><a href="apply/return" target="content">还车列表</a></dd>
                        <dd><a href="apply/all" target="content">全部数据</a></dd>
                    </dl>
                </li>
            </ul>
        </div>
    </div>
    <div class="layui-body" style="padding: 15px">
        <iframe name="content" width="100%" height="90%" frameborder="no" src="welcome"></iframe>
    </div>
    <div class="layui-footer">
        <!-- 底部固定区域 -->
        底部固定区域
    </div>
</div>

<script>
    $(function () {
        const element = layui.element;
    })

    function homeClick() {
        $(".layui-nav-item,dd").removeClass("layui-this")
    }

    function showUserWin() {
        layer.open({
            type: 2,
            content: "userinfo/edit?id=${loginInfo.id}",
            area: ["500px", "500px"]
        })
    }

    function showPasswordWin() {
        layer.open({
            type: 2,
            content: "userinfo/password",
            area: ["500px", "500px"]
        })
    }

    function logout() {
        layer.confirm('确定退出系统吗？', {icon: 3, title: "询问"}, function (index) {
            top.location.href = 'logout';
        })
    }
</script>
</body>
</html>

